﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using YArchitech.HVAC.AuxiliaryCurve;
using YArchitech.Revit;

namespace YArchitech.HVAC
{
	[Transaction(TransactionMode.Manual)]
	public class ModifyLineForDeatilLine : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			UIDocument activeUIDocument = commandData.Application.ActiveUIDocument;
			Document document = activeUIDocument.Document;
			Selection selection = activeUIDocument.Selection;
			List<ViewType> list = new List<ViewType>();
            list.Add((ViewType)1);
            list.Add((ViewType)2);
			if (!YJKRevitTools.ViewCheck(commandData.Application.ActiveUIDocument, list))
			{
				return Autodesk.Revit.UI.Result.Cancelled;
			}
			new HYModelLineFilter();
			Transaction transaction = new Transaction(document, "选择要定义的线");
			try
			{
				transaction.Start();
				new AuxiliaryCurveDefine(commandData).Define();
			}
			catch (Exception)
			{
				transaction.Dispose();
				return Autodesk.Revit.UI.Result.Cancelled;
			}
			transaction.Commit();
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
